package logic

import (
	"context"
	"ewaimai/waimairpc/models"

	"ewaimai/waimairpc/internal/svc"
	"ewaimai/waimairpc/waimairpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type OrderShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewOrderShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OrderShowLogic {
	return &OrderShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *OrderShowLogic) OrderShow(in *waimairpc.OrderShowRequest) (*waimairpc.OrderShowResponse, error) {
	// todo: add your logic here and delete this line
	var err error
	var o models.Order
	if err = o.GetOrderShow(int(in.Id)); err != nil {
		logx.Error("查询失败")
	}
	return &waimairpc.OrderShowResponse{
		OrderNo: o.OrderNo,
		Totam:   float32(o.Totam),
		Pay:     o.Pay,
		Xiadan:  o.Xiadan,
		Peisong: o.Peisong,
		Finish:  o.Finish,
		Jiedan:  o.Jiedan,
	}, nil
}
